import Vue from 'vue'
import VueRouter from 'vue-router'
import hasNav from '@/views/hasNav'
import coin from '@/views/coin'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: "hasNav",
    component:hasNav,
    redirect: '/home',
    children: [
      {
        path: 'home',
        name: "home",
        // component: function() {
        //   return import ('../views/Home')
        // },
        // 异步导入组件的方法
        component: () => import ('../views/Home')
      },
      {
        path: 'discover',
        name: "discover",
        component: () => import ('../views/discover')
      },
      {
        path: 'order',
        name: "order",
        component: () => import ('../views/order')
      },
      {
        path: 'profile',
        name: "profile",
        component: () => import ('../views/profile')
      }
    ]
  },
  // {
  //   path: '/home',
  //   name: "home",
  //   // component: function() {
  //   //   return import ('../views/Home')
  //   // },
  //   // 异步导入组件的方法
  //   component: () => import ('../views/Home')
  // },
  // {
  //   path: '/home/discover',
  //   name: "discover",
  //   component: () => import ('../views/discover')
  // },
  // {
  //   path: '/home/order',
  //   name: "order",
  //   component: () => import ('../views/order')
  // },
  // {
  //   path: '/profile',
  //   name: "profile",
  //   component: () => import ('../views/profile')
  // },
  {
    path: '/coin',
    name: "coin",
    component: coin
  },
  {
    path: '/detail',
    name: "detail",
    component: () => import ('../views/detail')
  }
]

// const routerPush = Router.prototype.push
// Router.prototype.push = function push(location) {
//   if(typeof(location)=="string"){
//     var Separator = "&";
//     if(location.indexOf('?')==-1) { Separator='?'; }
//     location = location + Separator + "random=" + Math.random();
//   }
//   return routerPush.call(this, location).catch(error=> error)
// }
const router = new VueRouter({
  routes
})

export default router
